package com.demo.controller;

import com.demo.response.Result;
import com.demo.service.QualityControlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "质控")
@RequestMapping("/quality")
@RestController
@Slf4j
public class QualityControlController {
    @Autowired
    QualityControlService qualityControlService;

    @ApiOperation("风险评估实施指标---VTE风险评估率")
    @GetMapping("/riskVteAssesProbability")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result riskVteAssesProbability(@RequestParam(name = "deptSn", required = false) String deptSn,
                                          @RequestParam(name = "startTime") String startTime,
                                          @RequestParam(name = "endTime") String endTime,
                                          @RequestParam(name = "timeType", defaultValue = "1") Integer timeType) {
        return qualityControlService.riskVteAssesProbability(deptSn, startTime, endTime, timeType);
    }

    @ApiOperation("风险评估实施指标---VTE中高危患者出血风险评估率")
    @GetMapping("/riskVteCrowningPatient")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result riskVteCrowningPatient(@RequestParam(name = "deptSn", required = false) String deptSn,
                                         @RequestParam(name = "startTime") String startTime,
                                         @RequestParam(name = "endTime") String endTime,
                                         @RequestParam(name = "timeType", defaultValue = "1") Integer timeType) {
        return qualityControlService.riskVteCrowningPatient(deptSn, startTime, endTime, timeType);
    }

    @ApiOperation("风险评估实施指标---VTE风险出院再评估率")
    @GetMapping("/riskVteDischargeDiagnosis")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result riskVteDischargeDiagnosis(@RequestParam(name = "deptSn", required = false) String deptSn,
                                            @RequestParam(name = "startTime", required = false) String startTime,
                                            @RequestParam(name = "endTime", required = false) String endTime,
                                            @RequestParam(name = "timeType", required = false, defaultValue = "1") Integer timeType) {
        return qualityControlService.riskVteDischargeDiagnosis(deptSn, startTime, endTime, timeType);
    }

    @ApiOperation("预防措施实施指标---内科高危患者预防比例")
    @GetMapping("/preventHighInnerPatient")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result preventHighInnerPatient(@RequestParam(name = "deptSn", required = false) String deptSn,
                                          @RequestParam(name = "startTime", required = false) String startTime,
                                          @RequestParam(name = "endTime", required = false) String endTime,
                                          @RequestParam(name = "timeType", required = false, defaultValue = "1") Integer timeType) {
        return qualityControlService.preventHighInnerPatient(deptSn, startTime, endTime, timeType);
    }

    @ApiOperation("预防措施实施指标---外科中/高危患者的预防比例")
    @GetMapping("/preventMiddleAndHighOuterPatient")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result preventMiddleAndHighOuterPatient(@RequestParam(name = "deptSn", required = false) String deptSn,
                                                   @RequestParam(name = "startTime", required = false) String startTime,
                                                   @RequestParam(name = "endTime", required = false) String endTime,
                                                   @RequestParam(name = "timeType", required = false, defaultValue = "1") Integer timeType) {
        return qualityControlService.preventMiddleAndHighOuterPatient(deptSn, startTime, endTime, timeType);
    }

    @ApiOperation("结局相关指标---医院内非预期死亡发生率")
    @GetMapping("/endingUnanticipatedDeath")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result endingUnanticipatedDeath(@RequestParam(name = "deptSn", required = false) String deptSn,
                                           @RequestParam(name = "startTime", required = false) String startTime,
                                           @RequestParam(name = "endTime", required = false) String endTime,
                                           @RequestParam(name = "timeType", required = false, defaultValue = "1") Integer timeType) {
        return qualityControlService.endingUnanticipatedDeath(deptSn, startTime, endTime, timeType);
    }

    @ApiOperation("结局相关指标---医院内PTE死亡发生率")
    @GetMapping("/endingUnanticipatedDeathPie")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result endingUnanticipatedDeathPie(@RequestParam(name = "deptSn", required = false) String deptSn,
                                              @RequestParam(name = "startTime", required = false) String startTime,
                                              @RequestParam(name = "endTime", required = false) String endTime,
                                              @RequestParam(name = "timeType", required = false, defaultValue = "1") Integer timeType) {
        return qualityControlService.endingUnanticipatedDeathPie(deptSn, startTime, endTime, timeType);
    }


    @ApiOperation("结局相关指标---PTE导致死亡占死亡总数比率")
    @GetMapping("/endingDeathPieContrastSum")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result endingDeathPieContrastSum(@RequestParam(name = "deptSn", required = false) String deptSn,
                                            @RequestParam(name = "startTime", required = false) String startTime,
                                            @RequestParam(name = "endTime", required = false) String endTime,
                                            @RequestParam(name = "timeType", required = false, defaultValue = "1") Integer timeType) {
        return qualityControlService.endingDeathPieContrastSum(deptSn, startTime, endTime, timeType);
    }

    @ApiOperation("结局相关指标---PTE死亡患者中未预防的比例")
    @GetMapping("/endingDeathPieNoPreventSum")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result endingDeathPieNoPreventSum(@RequestParam(name = "deptSn", required = false) String deptSn,
                                             @RequestParam(name = "startTime", required = false) String startTime,
                                             @RequestParam(name = "endTime", required = false) String endTime,
                                             @RequestParam(name = "timeType", required = false, defaultValue = "1") Integer timeType) {
        return qualityControlService.endingDeathPieNoPreventSum(deptSn, startTime, endTime, timeType);
    }


    @ApiOperation("诊治相关指标---PTE诊断成功率")
    @GetMapping("/endingPieSuccess")
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "timeType", required = true, value = "1 季度 2 季度 3 季度"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result endingPieSuccess(@RequestParam(name = "deptSn", required = false) String deptSn,
                                   @RequestParam(name = "startTime", required = false) String startTime,
                                   @RequestParam(name = "endTime", required = false) String endTime,
                                   @RequestParam(name = "timeType", required = false, defaultValue = "1") Integer timeType) {
        return qualityControlService.endingPieSuccess(deptSn, startTime, endTime, timeType);
    }

    @ApiOperation(value = "vte预防评估率", tags = {"质控", "v20210513更新"})
    @GetMapping({"/vtePreventionAdviceRate"})
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result vtePreventionAdviceRate(@RequestParam(name = "deptSn", required = false) String deptSn,
                                          @RequestParam(name = "startTime") String startTime,
                                          @RequestParam(name = "endTime") String endTime) {
        return qualityControlService.vtePreventionAdviceRate(deptSn, startTime, endTime);
    }

    @ApiOperation(value = "dvt诊断筛查率", tags = {"质控", "v20210513"})
    @GetMapping({"/dvtPreventionAdviceRate"})
    @ApiImplicitParams({@ApiImplicitParam(name = "deptSn", value = "部门编号"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", defaultValue = "2021-02-04"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", defaultValue = "2021-06-04")})
    public Result dvtPreventionAdviceRate(@RequestParam(name = "deptSn", required = false) String deptSn,
                                          @RequestParam(name = "startTime") String startTime,
                                          @RequestParam(name = "endTime") String endTime) {
        return qualityControlService.dvtPreventionAdviceRate(deptSn, startTime, endTime);
    }

}
